package com.tourismhengyang.impl;

import java.io.IOException;
import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.tourismhengyang.beans.Forum;
import com.tourismhengyang.biz.IForumBiz;
import com.tourismhengyang.dao.DBAccess;

public class ForumBizImpl implements IForumBiz {
	private DBAccess db = new DBAccess();
	
	@Override
	public int addComment(Forum fm) {
		SqlSession session = null;
		int result=0;
		try {
			session = db.getSqlSession();
			IForumBiz forumBiz = session.getMapper(IForumBiz.class);
			result = forumBiz.addComment(fm);
			session.commit();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			session.close();
		}
		return result;
	}

	@Override
	public List<Forum> getComments(int lid) {
		SqlSession session = null;
		List<Forum> result = null;
		try {
			session = db.getSqlSession();
			IForumBiz forumBiz = session.getMapper(IForumBiz.class);
			result = forumBiz.getComments(lid);
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			session.close();
		}
		return result;
	}

}
